import { createSlice } from "@reduxjs/toolkit";

export const counterSlice = createSlice({
  name: "user",
  initialState: {
    accessToken: "",
    refreshToken: "",
    userInfo: {},
  },
  reducers: {
    updateData(state, action) {
      state.accessToken = action.payload.accessToken;
      state.refreshToken = action.payload.refreshToken;
      state.userInfo = action.payload.userInfo;
    },
     clearData(state, action) {
      state.accessToken = '';
      state.refreshToken = '';
      state.userInfo = {};
    },
  },
});
// 每个 case reducer 函数会生成对应的 Action creators
export const { updateData,clearData } = counterSlice.actions;

export default counterSlice.reducer;
